<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/30 0030
 * Time: 14:26
 */

namespace app\mobile\controller;

use app\model\model\Ad;
use app\model\model\Label;
use app\model\model\News_type;
use app\model\model\Seo;
use app\model\model\Solution_type;
use app\model\model\Visiting;
use think\Request;
class Solution extends Base
{
    //实例化
    protected $_Seo;
    protected $_Ad;
    protected $_Solution;
    protected $_Solution_type;
    protected $_v;
    public function __construct(Request $request = null){
        parent::__construct($request);
        $this->_Solution_type = new Solution_type();
        $this->_Ad = new Ad();
        $this->_v = new Visiting();
        $this->_Solution = new \app\model\model\Solution();
        $this->_Seo = new Seo();
    }
    public function index(){
        //SEO
        $seo = $this->_Seo->getOne(['id'=>1]);
        $this->assign('seo',$seo);
        //banner
        $banner = $this->_Ad->getListHome(['type_id'=>55,'flag'=>1]);
        $this->assign('banner',$banner);
        //分类
        $type = $this->_Solution_type->getListSelect(true);
        $this->assign('type',$type);
        //列表
        if(input('type')){
            $list = $this->_Solution->getListSelect(['flag'=>1,'type_id'=>input('type')],true);
            foreach ($list as $v){
                $v['uname'] = str_replace(" ","-",$v['name']);
            }
            $this->assign('type1',input('type'));
        }else{
            $list = $this->_Solution->getListSelect(['flag'=>1],true);
            foreach ($list as $v){
                $v['uname'] = str_replace(" ","-",$v['name']);

            }
            $this->assign('type1',input(''));
        }

        $this->assign('list',$list);
        $typedata = $this->_Solution_type->getOne(16);
        $this->assign('typedata',$typedata);
        return $this->fetch();
    }
    public function type(){
        $id = input('id');
        //SEO
        $seo = $this->_Seo->getOne(['id'=>1]);
        $this->assign('seo',$seo);
        //banner
        $banner = $this->_Ad->getListHome(['type_id'=>55,'flag'=>1]);
        $this->assign('banner',$banner);
        $type = $this->_Solution_type->getOne($id);
        $this->assign('type',$type);
        $list = $this->_Solution->getListSelect(['type_id'=>$id]);
        foreach ($list as $v){
            $v['uname'] = str_replace(" ","-",$v['name']);

        }
        $this->assign('list',$list);
        return $this->fetch();
    }
    public function getListBytype(){
        if(input('type')){
            $list = $this->_Solution->getListSelect(['type_id'=>input('type'),'flag'=>1],true);
        }else{
            $list = $this->_Solution->getListSelect(['flag'=>1],true);
        }

        return json_echo_msg(200,'chenggong',$list);
    }
    public function view(){

        $id = input('name');
        $data = $this->_Solution->getOne($id);

        $this->assign('data',$data);

        return $this->fetch();
    }
}